<?= form_open("/program/now_page") ?>
<table border="0" width="100%" class="ui-widget">
	<tr>
		<td align="left"><input type="button" id="backButton" name="backButton" class="button2" value="ย้อนกลับสู่หน้าแรก" /></td>
		<td align="right"><input type="button" id="historyButton" name="historyButton" class="button" value="ข้อมูลเก่า" /></td>
	</tr>
</table>
<?= form_close() ?>
<table border="1" width="100%" class="table-data ui-widget">
	<thead>
		<tr class="ui-widget-header">
			<th align="center">Ext Code</th>
			<th align="center">จำนวนเส้นที่ผลิต</th>
			<th align="center">น้ำหนักรวม</th>
			<th align="center">% เกรด B</th>
			<th align="center">Film คงเหลือ</th>
			<th align="center">ชื่อสินค้า</th>
			<th align="center">เครื่อง</th>
		</tr>
	</thead>
	<tbody>
	<?
		$bool = FALSE;
		//print_r($program_result);
		$bool = FALSE;
		foreach($program_result as $item) { 
			$film_remaining = $item['weight'] - ($item["est_weight"] * $item["total_unit"]);
	?>
		<tr class="<?= ($bool) ? "odd" : "even" ?>">
			<td><a href="<?= site_url("/program/program_detail/" . $this->convert->AsciiToHex($item['program_code']) . "/" . $this->convert->AsciiToHex($item['product_dtl_id']) . "/0") ?>" class="link"><?= $item['program_code_ext'] ?></a></td>
			<td><?= number_format($item['total_unit'], 0) ?></td>
			<td><?= number_format($item['weight'], 0) ?></td>
			<td><?= number_format($item['grade_b'], 2) ?></td>
			<td><?= number_format($film_remaining, 0) ?></td>
			<td><?= $item["product_name_th"] ?></td>
			<td><?= isset($machine[$item["mc_id"]]) ? $machine[$item["mc_id"]] : "&nbsp;" ?></td>
		</tr>
	<? 		$bool = !$bool;
		} ?>
	</tbody>
</table>

<script type="text/javascript">
$(document).ready(function(){
	$(".button, .button2").button();
	$("#backButton").click(onBackButtonClick);
	$("#historyButton").click(onHistoryButtonClick);
});
function onBackButtonClick() {
	document.location.replace("<?= site_url("/main") ?>");
}
function onHistoryButtonClick() {
	document.location.href= "<?= site_url("/program/history") ?>";
}
</script>